package com.heima.behavior.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.common.exception.CustomException;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.pojos.ApParise;
import com.heima.behavior.mapper.ApPariseMapper;
import com.heima.behavior.service.IApPariseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.utils.common.UserThreadLocal;
import com.heima.utils.common.WmThreadLocalUtil;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 文章点赞表 服务实现类
 * </p>
 *
 * @author fkn
 * @since 2024-08-21
 */
@Service
public class ApPariseServiceImpl extends ServiceImpl<ApPariseMapper, ApParise> implements IApPariseService {

    @Override
    public void like(ApParise apParise) {
        save(apParise);
    }

    @Override
    public void unlike(ApParise apParise) {
        LambdaQueryWrapper<ApParise> condition = new LambdaQueryWrapper<ApParise>()
                .eq(ApParise::getUserId, apParise.getUserId())
                .eq(ApParise::getArticleId, apParise.getArticleId());
        remove(condition);
    }
}
